<?php if(count($ctx->getAlbum['result'])>0) { ?>

<tal:block tal:repeat="album  getAlbum/result">
<?php $count = count($ctx->album['AlbumRelations']);
	if(@$ctx->album['AlbumRelations'][0]['Groups'][0]['group_id'] != 0 && $ctx->album['added_by']==$_SESSION["sess_userid"])
	{
		$profPic = '/Uploads/users/'.$ctx->album['photo'];
		$otherCount = ($count-1);
				foreach($ctx->album['AlbumRelations'] as $group)
				{
					$group_ids[]= $group['Groups'][0]['group_id'];
				}
				//$others =  'and '.$otherCount.' other group(s)';
				$group_id = array_unique($group_ids);
				$otherCount = count($group_id)-1;
				//echo '<pre>';print_r($group_id);exit;
				//$count = 0;
		$name = '<a href=/album/index/album-view/'.base64_encode($ctx->type).'/'.base64_encode($ctx->album["album_id"]).'>'.$ctx->album["title"].'</a>  album shared to '.$ctx->album["AlbumRelations"][0]["Groups"][0]["name"];
		//$name = $ctx->album['first_name']." shared ".$ctx->album['title']." album to ".$ctx->album['AlbumRelations'][0]['Groups'][0]['name'];
		if($otherCount>0)
		{
		$others =  'and '.$otherCount.' other group(s)';
		
		} 
		else {
		$others="";
		
		}
			$shareTpye = 'Shared';
			$shareIcon = 'SendIconSm.png';
			$shareAlt = "Sent";
		//$count = 0;
		//echo $name;exit;
	} 
	else
	{
	//hari nath shared test album to chandra and 2 other gorups
		if($ctx->album['added_by']==$_SESSION["sess_userid"] && $ctx->album['AlbumRelations'][0]['is_owner'] != 1)
		{
		$profPic = '/Uploads/users/'.$ctx->album['photo'];
		$name = ' <a href=/album/index/album-view/'.base64_encode($ctx->type).'/'.base64_encode($ctx->album['album_id']).'>'.$ctx->album["title"].'</a>  shared to public';

		//$name =$ctx->album['first_name']." shared ".$ctx->album['title']." album to public ";
		
			$others = "";
			$shareTpye = 'Shared';
			$shareIcon = 'SendIconSm.png';
			$shareAlt = "Sent";
		}
		else
		{
		$profPic = '/Uploads/users/'.$ctx->album['photo'];
		$name ='<a href=/album/index/album-view/'.base64_encode($ctx->type).'/'.base64_encode($ctx->album['album_id']).'>'.$ctx->album["title"].'</a> personal';
		//$name = $ctx->album['title']."  personal";
		$others = "";
		//echo $ctx->album['AlbumRelations'][0]['is_owner'];
		if($ctx->album['AlbumRelations'][0]['is_owner'] == 1)
		{
			$shareIcon = '';
			$shareAlt = "";
		} else {
			//echo $ctx->album['AlbumRelations'][0]['owner_id'];
			$shareIcon = 'ReceiveIconSm.png';
			$shareAlt = "Received";
			$name = '<a href=/album/index/album-view/'.base64_encode($ctx->type).'/'.base64_encode($ctx->album['album_id']).'>'.$ctx->album["title"].'</a>  album shared by  '.$ctx->album["first_name"];
			//$name = $ctx->album['title']." album shared by ".$ctx->album['first_name'];
		}
		$shareTpye = 'Personal';
		
		}
	}




	
	if(count($ctx->album['AlbumRelations'][0]['MyFavorites'])>0)
	{
		$user_id = $ctx->album['AlbumRelations'][0]['MyFavorites']['owner_id'];
		$favorite_status = $ctx->album['AlbumRelations'][0]['MyFavorites']['status'];
		
		
	} else {
		$favorite_status = 'Inactive';
		//echo $favorite_status;exit;
		$user_id = '';
	}
	//echo $ctx->album['AlbumRelations'][0]['read_status'];exit;
 ?>
<div class="PhoVid">
<?php if($ctx->album['AlbumRelations'][0]['read_status'] == 0) { $class="act";} else { $class="nor"; } ?>
<div class="<?php echo $class;?>">
<div class="blkCont">
<div class="Icon"><img src="/images/PhotoIconUser.png" /></div>
<p class="UserImg">
<img src="<?php echo $profPic; ?>" height="45" width="45" alt="Profile" title="Profile"/></p>
<p class="Date"> <?php echo date('M d y',strtotime($ctx->album['added_date']));?></p>
</div>
<div class="blkCont">
<div class="wid240">
<p class="Title"><?php echo $name;?></p>
<p class="Desc"><span tal:content="structure php: this.SubStrText(album['description'], 50)">Des Here</span></p>
<?php if($shareTpye =='Personal' && $shareIcon=='') { ?>
<span><a id="create" href="javascript:void(0);" onclick="shareAlbum(<?php echo $ctx->album['album_id']; ?>,'share');" class="UserShare">Share</a></span>
<?php } else { ?>
<?php if(isset($ctx->album['cnt']) && $ctx->album['cnt']!='') { 
	$cnt = $ctx->album['cnt']; 
	} else {
	$cnt = 0;
//echo $cnt;exit;	
	}
?>

<?php } ?>
<?php if($ctx->album['eventName']!='') { ?>
<span><a href="javascript:void(0);" class="CaleLink" title="<?php echo $ctx->album['eventName'];?>" ><?php if(strlen($ctx->album['eventName'])>20) { echo substr($ctx->album['eventName'],0,20).'...';} else { echo $ctx->album['eventName']; } ?></a></span>
<?php } ?>
</div>
</div>
<div class="blkContRt">
<?php $count = count($ctx->album['AlbumRelations']);
//echo $count;exit;
if($count>1)
{
	
	$id=$ctx->album['album_id'];
	$type="album_id";
	
}
else
{
	$id=$ctx->album['AlbumRelations'][0]['id'];
	$type="relation_id";
}
//echo $user_id.'--'.$favorite_status;exit;
 ?>
 <?php if($shareIcon != '') { ?>
  <span><img src="/images/<?php echo $shareIcon;?>" alt="<?php echo $shareAlt;?>" title="<?php echo $shareAlt;?>" /></span>
 <?php } ?>
 <?php if($favorite_status=="Active"&& $user_id==$_SESSION["sess_userid"]){?>
<a href="javascript:void(0);" onclick="changeStatusFavorite(<?php echo $ctx->album['album_id'];?>,'Inactive')"><img src="/images/FavorIconAct.png" alt="Favorite" title="Favorite" /></a>
<? } else {?>
<a href="javascript:void(0);" onclick="changeStatusFavorite(<?php echo $ctx->album['album_id'];?>,'Active')"><img src="/images/FavorIconNor.png" alt="Favorite" title="Favorite" /></a>
<? } ?>
<span><a href="javascript:void(0);" onclick="deleteAlbum(<?php echo $id;?>,'<?php echo $type;?>');"><img src="/images/CloseIcon.png" alt="Close" border="0" class="img_inline" title="Delete"/></a></span>

</div>
<div class="clear"></div>
</div>
<div class="clear"></div>
</div>
</tal:block>

<?php } else { ?>
<p style="padding:100px 100px"><b><center>No albums found</center></b></p>
<?php } ?>
<script type="text/javascript">
//<![CDATA[

	pagination1 = new Array();
	pagination1['currentPage'] = "<?=$ctx->getAlbum['currentPage']?>";
	pagination1['resultsPerPage'] = "<?=$ctx->getAlbum['resultPerPage']?>";
	pagination1['pages'] = "<?= $ctx->getAlbum['pages']?>";  
	pagination1['pager'] = '<?=$ctx->getAlbum["pager"]?>';
	pagination1['resultsCount'] = "${getAlbum/resultsCount}" ;
	
	var Params='${params}';
	var ParamsDup='';
	//alert(pagination['resultsCount']+'  '+Params);
	var requestUrlDup = "/album/index/pagination/<?php echo $ctx->type; ?>/";
	//var requestUrlDup = "/user/myhome/ajax-news/0/";
	$(document).ready(function () {
	   setPagination1(pagination1['resultsCount'],'','downPagerId1','','');
	});
//]]>
</script>


